#ifndef LAURIN_CONTROLLER_H_
#define LAURIN_CONTROLLER_H_

#include "../core/laurin-discover-network-clients-module.h"
#include "../core/laurin-discover-devices-module.h"
#include "../core/laurin-utils.h"
#include "laurin-80211-networks-model.h"
#include <gtkmm/treestore.h>
#include <glibmm/ustring.h>


#define LAURIN_DISCOVER_NETWORK_CLIENTS_MODE 0x0001
#define LAURIN_DISCOVER_DEVICES_MODE	0x0002
#define LAURIN_LOCATION_MODE	0x0004


struct LaurinControllerOptions
{
	LaurinControllerOptions()
	{
		operation_mode = LAURIN_DISCOVER_NETWORK_CLIENTS_MODE;
		discover_max_frame = 1000;
		network_frame_timeout = 2;
		discover_timeout = 60;
		network_device_name = "wlan0";
		monitor_device_name = "mon0";
		monitor_device_master_name = "wmaster0";
	};

	bool areValid()
	{
		if(operation_mode & LAURIN_DISCOVER_NETWORK_CLIENTS_MODE)
			return !network_device_name.empty() && network_frame_timeout > 0;

		if(operation_mode & LAURIN_DISCOVER_DEVICES_MODE)
			return !monitor_device_name.empty() && !monitor_device_master_name.empty() && discover_max_frame > 0 && discover_timeout > 0;

		return false;
	}

	short operation_mode;
	int discover_max_frame;
	int network_frame_timeout;
	int discover_timeout;

	Glib::ustring network_device_name;
	Glib::ustring monitor_device_name;
	Glib::ustring monitor_device_master_name;
};

class LaurinController
{

	public:

		LaurinController();
		~LaurinController();

		LaurinControllerOptions getOptions() const;
		void setOptions(LaurinControllerOptions options);

		bool start();
		void stop();
		bool isRunning() const;

		void fillModel(Laurin80211NetworksModel* model);

	private:

		LaurinControllerOptions _options;
		LaurinDiscoverDevicesModule* _devices;
		LaurinDiscoverNetworkClientsModule* _clients;
};

#endif
